<include file="admin_header" />
<div id="container" class="so_main">
  <!-- START TAB框 -->
  <php>if(!empty($pageTab) || C('DEVELOP_MODE')==true):</php>
  <div class="tit_tab">
    <ul>
    <php> !$_REQUEST['tabHash'] && $_REQUEST['tabHash'] =  $pageTab[0]['tabHash'];</php>
    <volist name='pageTab' id='t'>
    <li><a href="{$t.url}&tabHash={$t.tabHash}" <php> if($t['tabHash'] == $_REQUEST['tabHash']){ echo 'class="on"';}</php>>{$t.title}</a></li>
    </volist>
    </ul>
    <div class="page_tit">
      <php>if(C('DEVELOP_MODE')==true){</php>
      <span onclick="admin.fold('page_config')">{:L('PUBLIC_PAGE_CONFIGURATION')}</span><php>if(!empty($searchKeyList)):</php>
      <span onclick="admin.fold('search_config')">{:L('PUBLIC_SEARCH_PAGE')}</span><php>endif;</php>
      <php>}</php>
    </div>
  </div>
  <php>endif;</php>
  <!-- END TAB框 -->

  <!-- START 页面配置 -->
  <div id='page_config' class = "form2 list" >
      <div class="hd">{:L('PUBLIC_CHECH_IS')}</div>
      <form action="{:U('admin/Index/savePageConfig')}" method="POST">
      <input type="hidden" name='pageKey' value="{$pageKey}"  class="s-txt"/>
      <input type="hidden" name='pageTitle' value="{$pageTitle}" />
      <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tr>
          <th>{:L('PUBLIC_SYSTEM_FIELD')}</th>
          <th class="line_l">{:L('PUBLIC_ADMIN_TITLE')}</th>
          <th class="line_l">{:L('PUBLIC_HEIDDEN_TIPS')}</th>
          <th class="line_l">{:L('PUBLIC_CLICK_TIPES')}</th>
        </tr>
        <volist name='pageKeyList' id='pk'>
        <php> $key = $pk;$keyType = $pageKeyData['key_type'][$key];</php>
        <tr overstyle="on" >
          <td width="20%"> <input type="hidden" name='key[]' value='{$pk}'> {$pk}</td>
          <td width="30%"><input type="text" name='key_name[]' value='{$pageKeyData['key_name'][$key]}'  class="s-txt" style="width:200px" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" /></td>
          <td width="20%">
          <select name="key_hidden[]">
            <option value="0" <php>if($pageKeyData['key_hidden'][$key]=='0'){ echo 'selected="selected"';}</php>>{:L('PUBLIC_SHOW')}</option>
            <option value="1" <php>if($pageKeyData['key_hidden'][$key]=='1'){ echo 'selected="selected"';}</php>>{:L('PUBLIC_HIDDEN')}</option>
          </select>
          </td>
          <td width="30%"><input type='text' name='key_javascript[]' value='{$pageKeyData['key_javascript'][$key]}'  class="s-txt" style="width:200px" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" ></td>
          <!-- <td style="background-color:#1E325C">
          <a onclick="admin.moveUp($(this))" class="ico_top" title="上移"><img src="{:THEME_PUBLIC_URL}/admin/image/zw_img.gif"></a> &nbsp;&nbsp;
          <a onclick="admin.moveDown($(this))" class="ico_btm" title="下移"><img src="{:THEME_PUBLIC_URL}/admin/image/zw_img.gif"></a>
          </td> -->
        </tr>
        </volist>
      </table>
      <div class="page_btm">
        <input type="submit" class="btn_b" value="确定" />
      </div>
      </form>
    </div>
  <!-- END 页面配置 -->
  
  <!-- START 搜索配置 -->
  <div id='search_config' class = "form2 list" >
      <div class="hd">提示:checkbox如果默认有多个值,请以","隔开。</div>
      <form action="{:U('admin/Index/saveSearchConfig')}" method="POST">
      <input type="hidden" name='searchPageKey' value="{$searchPageKey}" />
      <input type="hidden" name='pageTitle' value="{$pageTitle}" />
      <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tr>
          <th>字段</th>
          <th class="line_l">名称</th>
          <th class="line_l">输入类型</th>
          <th class="line_l">提示信息</th>
          <th class="line_l">验证事件</th>
        </tr>
        <volist name='searchKeyList' id='pk'>
        <php> 
        $key = is_array($pk) ? $pk[0] : $pk;
        $keyType = $searchKeyData['key_type'][$key];
        if(is_array($pk)){ $pk = $pk[0];}
        </php>
        <tr overstyle="on" >
          <td width="15%"><input type="hidden" name='key[]' value='{$pk}'> {$pk}</td>
          <td width="20%"><input type="text" name='key_name[]' value='{$searchKeyData['key_name'][$key]}' class="s-txt"   style="width:200px" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" /></td>
          <td width="20%"><select name='key_type[]'>
            <option value='text' <eq name='keyType' value='text'> selected="selected"</eq>>文本框:input_text</option>
            <option value='select' <eq name='keyType' value='select'> selected="selected"</eq>>下拉框:select</option>
            <option value='radio' <eq name='keyType' value='radio'> selected="selected"</eq>>单选框:radio</option>
            <option value='checkbox' <eq name='keyType' value='checkbox'> selected="selected"</eq>>多选框:checkbox</option>
            <option value='date' <eq name='keyType' value='date'> selected="selected"</eq>>日期插件:date</option>
            <option value='hidden' <eq name='keyType' value='hidden'> selected="selected"</eq>>隐藏值:input_hidden</option>
            <option value='department' <eq name='keyType' value='department'> selected="selected"</eq>>部门选择:department</option>
            <option value='user' <eq name='keyType' value='user'> selected="selected"</eq>>用户选择:selectUser</option>
          </select></td>
          <td width="20%"><input type='text' name='key_tishi[]' value='{$searchKeyData['key_tishi'][$key]}' class="s-txt"  style="width:200px"  onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" ></td>
          <td width="20%"><input type='text' name='key_javascript[]' value='{$searchKeyData['key_javascript'][$key]}' class="s-txt"  style="width:200px" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" ></td>
        </tr>
        </volist>
      </table>
      <div class="page_btm">
        <input type="submit" class="btn_b" value="确定" />
      </div>
      </form>
    </div>
    <!-- END 搜索配置 -->
    
  <php>if(!empty($pageButton) || !empty($listData['html'])):</php>
   <!-- START TOOLBAR -->
  <div class="Toolbar_inbox">
    <div class="page right">
    共&nbsp;&nbsp;{$listData.totalRows}&nbsp;&nbsp;条记录&nbsp;&nbsp;{$listData.html}
    </div>  
    <volist name='pageButton' id='b'>
      <a onclick="{$b.onclick}" class="btn_a"><span>{$b.title}</span></a>
    </volist>
  </div>
  <!-- END TOOLBAR -->
  <php>endif;</php>
    
  <!-- START 搜索框 -->
  <div class="form2" id='search_form' <php> echo $_REQUEST['dosearch'] =='1'? "style='display:block;'":'';</php>>
  <form action="{$searchPostUrl}&dosearch=1" method="post">
  <volist name='searchKeyList' id='pk'>
    <php>
    $_pk = $pk;
    is_array($pk) && $pk = $pk[0];
    $key = is_array($pk) ? $pk[0] : $pk;
    $keyName = $searchKeyData['key_name'][$key] ? $searchKeyData['key_name'][$key] :$pk; 
    $defaultS = isset($searchData[$pk]) ? $searchData[$pk] : '';
    $keyType = $searchKeyData['key_type'][$key] ? $searchKeyData['key_type'][$key] :'text';
    $event = $searchKeyData['key_javascript'][$key];
    if($keyType != 'hidden'):/*非隐藏域*/ 
    </php>
    <dl class="lineD" id='dl_{$pk}'>
      <dt>{$keyName}：</dt>
      <dd>
    <php>endif; /*非隐藏域*/ </php>
  
        <php>
        /* text 支持一行多个 */
        if($keyType == 'text'):
        if(is_array($_pk)){
          foreach($_pk as $v=>$vv){
        </php>
          <input name="{$pk}[]" id="form_{$pk}_{$v}" type="text" value="{$defaultS[$v]}" <neq name='event' value=''> onfocus = "{$event}"</neq>  class='s-txt' style="width:200px" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" > 
          <php> echo $v = (count($_pk)-1) ? '':' - ';</php>
        <php> 
          }
        }else{
        </php>
        <input name="{$pk}" id="form_{$pk}" type="text" value="{$defaultS|t}" <neq name='event' value=''> onfocus = "{$event}"</neq> class='s-txt' style="width:200px" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" >
        <php>}endif;</php>
        
        <php>if($keyType == 'department'):</php>
        {:W('Department',array('inputName'=>$pk,'canChange'=>1,'tpl'=>'input','notop'=>1,'defaultName'=>$searchData['department_show'],'defaultId'=>intval($defaultS)))}
        <php>endif;</php>

        <php>
        if($keyType == 'select'):
        </php>
        <select name="{$pk}" id="form_{$pk}" <neq name='event' value=''> onchange = "{$event}"</neq> class='s-select' style="width:200px">
          <php>foreach($opt[$pk] as $sk=>$sv):</php>
            <option value="{$sk}" <php>if($sk == $defaultS):</php> selected="selected" <php>endif;</php>>{$sv}</option>
          <php> endforeach;</php>
        </select>
        <php>endif;</php>

        <php>if($keyType == 'user'):</php>
         {:W('SearchUser', array('uids'=>$defaultS, 'name'=>$pk,'follow'=>0, 'noself'=>0, 'max'=>0))}  
        <php>endif;</php>
        
        <php>
        if($keyType == 'radio'):
          $nums = count($opt[$pk]);
          $tempi = 1;
          foreach($opt[$pk] as $sk=>$sv):
            $br = $nums >=6  && $tempi%3==0 ? '<br/>':'';
            $tempi++; 
        </php>
        <label><input type="radio" name="{$pk}" value='{$sk}' <php>if($sk == $defaultS):</php> checked="checked"<php>endif;</php> <neq name='event' value=''> onfocus = "{$event}"</neq> >{$sv} </label> {$br}              
        <php>endforeach; endif;</php>
        
          <php>
        /* checkBox 默认值是以","隔开的字符串,表示可以选多个  */
        if($keyType == 'checkbox'):
          empty($defaultS) && $defaultS = array(); 
          $defaultS = !is_array($defaultS) ? explode(',',trim($defaultS,',')) : $defaultS;
          foreach($opt[$pk] as $sk=>$sv):
        </php>  
        <label><input type="checkbox" name="{$pk}[]" value='{$sk}' <php>if(in_array($sk,$defaultS)):</php> checked="checked"<php>endif;</php> <neq name='event' value=''> onfocus = "{$event}"</neq> >{$sv} </label>
        <php>endforeach; endif;</php>
        
        
          <php>
        /* 日期插件 支持一行多个*/
        if($keyType == 'date'): 
        if(is_array($_pk)){
          foreach($_pk as $v=>$vv){
        </php> 
          {:W('DateSelect',array('name'=>$pk."[]",'class'=>'s-txt','id'=>'from_'.$pk.'_'.$v,'value'=>$defaultS[$v],'dtype'=>'full'))}
          <php> echo $v == (count($_pk)-1) ? '':' — ';</php>
        <php> 
          }
        }else{
        </php>
        <input name="{$pk}" type="text" class="s-txt" id="form_{$pk}" value='{$defaultS}' onfocus="core.rcalendar(this,'full');" readonly="readonly" style="width:200px;" onblur="this.className='s-txt'" onfocus="this.className='s-txt-focus'" />
        <php>}endif;</php>
        
         <php>if($keyType == 'hidden'):</php>
        <input name="{$pk}" id="form_{$pk}" type="hidden" value="{$defaultS}"  class='s-txt'>
        <php>endif;</php>
        
         <php> if(!empty($searchKeyData['key_tishi'][$key])){</php>
        <p>{$searchKeyData['key_tishi'][$key]}</p>
        <php> }</php>
     
       <php>if($keyType != 'hidden'): /*非隐藏域*/</php> 
        </dd>
    </dl>
    <php>endif; /*隐藏域*/ </php>
  </volist>
    <div class="page_btm">
      <input type="submit" value="确定" class="btn_b"> &nbsp;&nbsp;<input type="button" value="关闭" class="btn_w" onclick="admin.fold('search_form')">
    </div>
    </form>
   </div> 
  <!-- END 搜索框 -->

  <!-- START LIST -->
  <div class="list" id='list'>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
 	
 	<php> if($allSelected):</php>
    <th>
        <input type="checkbox" id="checkbox_handle" onclick="admin.checkAll(this)" value="0">
    </th>
    <php>endif;</php>
    
   <volist name='pageKeyList' id='pk'>
   	<php> 
   	$key = $pk;
   	if($pageKeyData['key_hidden'][$key]=='1'){ continue;}
   	$name = $pageKeyData['key_name'][$key] ? $pageKeyData['key_name'][$key] : $pk; </php>
    <th class="line_l">{$name}</th>
	</volist>
  </tr>
  <php>if(empty($listData['data'])){</php>
  <tr><td colspan='100' align="center">没有需要显示的数据!</td></tr>
  <php>}else{</php>
  
  <volist name='listData.data' id='vo'>
  <tr overstyle="on" id="tr<php>echo $vo[$_listpk];</php>">
  
  <php> if($allSelected):</php>
  <td><input type="checkbox" value="<php>echo $vo[$_listpk];</php>" onclick="admin.checkon(this)"  name="checkbox"></td>
  <php> endif;</php>
  <volist name='pageKeyList' id='pk'>
  <php>
  $key = $pk;
  if($pageKeyData['key_hidden'][$key]=='1'){ continue;}
  $event = $pageKeyData['key_javascript'][$key];
  </php>
  <td <neq name='event' value=''> onclick = "{$event}"</neq>>
  <php> echo $vo[$pk];</php>
  </td>
  </volist>
  </tr>	
  </volist>
  <php>}</php>
  
  </table>
  </div>
  <!-- END LIST -->
  <php>if(!empty($listData['html'])):</php>
  <!-- START BOTTOMBAR -->
  <div class="Toolbar_inbox">
    <div class="page right">
    共&nbsp;&nbsp;{$listData.totalRows}&nbsp;&nbsp;条记录，{$listData.html}
    </div>
  </div>
  <!-- END BOTTOMBAR -->
  <php>endif;</php>
</div>
<include file="admin_footer" />
